package com.rmt.www.action;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.rmt.www.constant.RequestType;
import com.rmt.www.dao.ArtifactDao;
import com.rmt.www.dao.ProjectDao;
import com.rmt.www.dao.RequestDao;
import com.rmt.www.dao.UserDao;
import com.rmt.www.service.DevManageDesignService;
import com.rmt.www.service.DevManageImplService;
import com.rmt.www.utility.SystemTime;
import com.rmt.www.vo.Artifact;
import com.rmt.www.vo.ImplementationArtifactRequest;
import com.rmt.www.vo.Project;
import com.rmt.www.vo.Request;
import com.rmt.www.vo.User;


public class UpdateImplementationSubmitAction extends ActionSupport{
	private static final long serialVersionUID = 1L;
	
	private int pid;
	private int aid;
	private String title;
	private String function;
	private String input;
	private String output;
	private String processingsteps;
	private String algorithm;
	private String errorhandling;
	private String language;
	private String code;
	private String priority;
	private int effort;
	private String cost;
	private String risk;
	private String comment;
	private int createrid;
	private Timestamp createdtime;
	private int updaterid;
	private Timestamp updatedtime;
	private int updatedtimes;
	private String version;
	private String status;
	private int implartifactid;
	private String requesttype;
	
	private DevManageImplService devManageImplService;
	
	
	public int getAid() {
		return aid;
	}


	public void setAid(int aid) {
		this.aid = aid;
	}


	public String getTitle() {
		return title;
	}


	public void setTitle(String title) {
		this.title = title;
	}


	public int getPid() {
		return pid;
	}


	public void setPid(int pid) {
		this.pid = pid;
	}


	public String getFunction() {
		return function;
	}


	public void setFunction(String function) {
		this.function = function;
	}


	public String getInput() {
		return input;
	}


	public void setInput(String input) {
		this.input = input;
	}


	public String getOutput() {
		return output;
	}


	public void setOutput(String output) {
		this.output = output;
	}


	public String getProcessingsteps() {
		return processingsteps;
	}


	public void setProcessingsteps(String processingsteps) {
		this.processingsteps = processingsteps;
	}


	public String getAlgorithm() {
		return algorithm;
	}


	public void setAlgorithm(String algorithm) {
		this.algorithm = algorithm;
	}


	public String getErrorhandling() {
		return errorhandling;
	}


	public void setErrorhandling(String errorhandling) {
		this.errorhandling = errorhandling;
	}


	public String getLanguage() {
		return language;
	}


	public void setLanguage(String language) {
		this.language = language;
	}


	public String getCode() {
		return code;
	}


	public void setCode(String code) {
		this.code = code;
	}


	public String getPriority() {
		return priority;
	}


	public void setPriority(String priority) {
		this.priority = priority;
	}


	public int getEffort() {
		return effort;
	}


	public void setEffort(int effort) {
		this.effort = effort;
	}


	public String getCost() {
		return cost;
	}


	public void setCost(String cost) {
		this.cost = cost;
	}


	public String getRisk() {
		return risk;
	}


	public void setRisk(String risk) {
		this.risk = risk;
	}


	public String getComment() {
		return comment;
	}


	public void setComment(String comment) {
		this.comment = comment;
	}


	public int getCreaterid() {
		return createrid;
	}


	public void setCreaterid(int createrid) {
		this.createrid = createrid;
	}


	public Timestamp getCreatedtime() {
		return createdtime;
	}


	public void setCreatedtime(Timestamp createdtime) {
		this.createdtime = createdtime;
	}


	public int getUpdaterid() {
		return updaterid;
	}


	public void setUpdaterid(int updaterid) {
		this.updaterid = updaterid;
	}


	public Timestamp getUpdatedtime() {
		return updatedtime;
	}


	public void setUpdatedtime(Timestamp updatedtime) {
		this.updatedtime = updatedtime;
	}


	public int getUpdatedtimes() {
		return updatedtimes;
	}


	public void setUpdatedtimes(int updatedtimes) {
		this.updatedtimes = updatedtimes;
	}


	public String getVersion() {
		return version;
	}


	public void setVersion(String version) {
		this.version = version;
	}


	public String getStatus() {
		return status;
	}


	public void setStatus(String status) {
		this.status = status;
	}


	public int getImplartifactid() {
		return implartifactid;
	}


	public void setImplartifactid(int implartifactid) {
		this.implartifactid = implartifactid;
	}


	public String getRequesttype() {
		return requesttype;
	}


	public void setRequesttype(String requesttype) {
		this.requesttype = requesttype;
	}
	


	public DevManageImplService getDevManageImplService() {
		return devManageImplService;
	}


	public void setDevManageImplService(DevManageImplService devManageImplService) {
		this.devManageImplService = devManageImplService;
	}


	public String execute(){
		ImplementationArtifactRequest r = new ImplementationArtifactRequest();
		r.setPid(pid);
		r.setImplartifactid(aid);
		r.setTitle(title);
		r.setFunction(function);
		r.setInput(input);
		r.setOutput(output);
		r.setProcessingsteps(processingsteps);
		r.setAlgorithm(algorithm);
		r.setErrorhandling(errorhandling);
		r.setLanguage(language);
		r.setCode(code);
		r.setCreaterid(createrid);
		r.setCreatedtime(createdtime);
		r.setPriority(priority);
		r.setEffort(effort);
		r.setCost(cost);
		r.setRisk(risk);
		r.setComment(comment);
		r.setUpdatedtimes(updatedtimes);
		r.setVersion(version);
		r.setStatus(status);
		User u=(User)ActionContext.getContext().getSession().get("currentUser");
		r.setUpdaterid(u.getUid());
		//还要设置updatedtime为当前时间
		r.setUpdatedtime(new java.sql.Timestamp(SystemTime.getSystemTime().getTime()));
		
		r.setRequesttype(RequestType.UPDATE);
		
		devManageImplService.addImplementationRequest(r);
		
		/*ActionContext ctx = ActionContext.getContext();        
		HttpServletRequest request = (HttpServletRequest)ctx.get(ServletActionContext.HTTP_REQUEST); 
		request.setAttribute("pid", pid);*/
		
		return "success";
		
	}
}
